package com.demo.salary.abstracttransactions;

import com.demo.salary.payrolldomain.Employee;
import com.demo.salary.payrolldatabase.PayrollDatabase;
import com.demo.salary.transactionapplication.Transaction;

public abstract class ChangeEmployeeTransaction implements Transaction {

    int empId;

    public ChangeEmployeeTransaction(int empId) {
        this.empId = empId;
    }

    public abstract void change(Employee employee);


    @Override
    public void execute() {
        Employee employee = PayrollDatabase.getEmployee(empId);
        if (employee == null) {
            throw new RuntimeException("员工不存在");
        }

        change(employee);

    }
}
